# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.

import pymysql


def execute(cursor):
    cursor.execute("DROP TABLE IF EXISTS py_employee")
    sql = """
    CREATE TABLE py_employee (
        first_name char(20) not null,
        last_name char(20),
        age int,
        income float
    )
    """
    cursor.execute(sql)


def connect():
    db = pymysql.connect(user="lark", password="0915", host="localhost", database="test")
    cursor = db.cursor()
    cursor.execute("SELECT VERSION()")
    data = cursor.fetchone()
    print("connect mysql : %s" % data)
    execute(cursor)
    db.close()


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    connect()
